﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="WinMsgUtils.cs" company="" />
// <summary>
//   Abstraction over Windows messages framework.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace FormsUtilities
{
    using System;
    using System.Runtime.InteropServices;

    /// <summary>
    /// Abstraction over Windows messages framework.
    /// </summary>
    public class WinMsgUtils
    {
        /// <summary>
        /// PInvoking Windows 'SendMessage' method.
        /// See:
        /// Windows messages definitions: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644927(v=vs.85).aspx#system_defined
        /// Windows messages constants:   http://www.pinvoke.net/default.aspx/Constants.WM
        /// </summary>
        /// <param name="hWnd">The handle of the window to send message to.</param>
        /// <param name="wMsg">The type of the message.</param>
        /// <param name="wParam">Short value parameter. Depends on the message used.</param>
        /// <param name="lParam">Long value parameter. Depends on the message used.</param>
        /// <returns>Depends on the message used.</returns>
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);

        #region Message Type Constants

        public const int WM_HSCROLL = 0x114;

        #endregion

        #region Message Parameter Values and Enums

        public enum ScrollBarCommands
        {
            SB_LINEUP = 0,
            SB_LINELEFT = 0,
            SB_LINEDOWN = 1,
            SB_LINERIGHT = 1,
            SB_PAGEUP = 2,
            SB_PAGELEFT = 2,
            SB_PAGEDOWN = 3,
            SB_PAGERIGHT = 3,
            SB_THUMBPOSITION = 4,
            SB_THUMBTRACK = 5,
            SB_TOP = 6,
            SB_LEFT = 6,
            SB_BOTTOM = 7,
            SB_RIGHT = 7,
            SB_ENDSCROLL = 8
        }

        #endregion
    }
}
